package com.zy.design.pattern.observer.syn;

/**
 * @author zhaoyi
 * @date 2021/4/25 14:27
 */
public class LoginObservable extends SimpleObservable {

    public void login(String username,String password){

        if (username == null || username.isEmpty() || password == null || password.isEmpty()){
            System.out.println("******登录失败****");
            return;
        }

        System.out.println("~~~~登录成功~~~~~");
        //登录失败抛异常
        LoginMessage message = new LoginMessage("登录", username.hashCode());
        notifyObservers(message);

    }

}
